Field of the Invention
Embodiments of the present invention relate generally to graphics processing and, more particularly, to multi-pass rendering in a screen space pipeline.
Description of the Related Art
A conventional graphics processing unit (GPU) includes one or more graphics pipelines that may be configured to generate geometry within a three-dimensional (3D) scene. A given graphics pipeline may draw geometry in the graphics scene in a particular order relative to a viewing position from which the scene is ultimately rendered. For example, a graphics pipeline could generate geometry associated with the background of the scene, relative to the viewing position, and then subsequently generate geometry associated with the foreground of the scene. In this example, the scene geometry is generated “back to front.” The order in which the geometry is generated is typically controlled by a software application that relies on the GPU for graphics processing operations. This order is known in the art as application programming interface (API) order. The software application could be, for example, a video game or a 3D simulation program that executes on the computer system that is responsible for rendering the images of the 3D scene for display.
In the graphics pipeline, after the geometry is generated, hardware or software shaders are usually executed to generate pixel values based on the geometry in the 3D scene. The shaders typically operate on the geometry according to the API order with which the geometry was initially generated. Thus, returning to the above example, the shader would generate pixel values for the background of the 3D scene and then generate pixel values for the foreground of the 3D scene. However, inefficiencies may arise with this approach when elements of the foreground occlude portions of the background, making those portions invisible from the viewing position. In particular, any pixel values generated based on the occluded portions of the geometry do not contribute to the final rendered image, so the work expended to generate those pixel values is wasted.
One solution to this problem is to program the GPU, via the software application, to perform an operation known as a “Z pre-pass.” When performing a Z pre-pass operation, the graphics pipeline renders only the positions associated with the geometry and then performs a depth test across all resulting pixels or samples to identify occluded pixels and sample that are occluded. The graphics pipeline may then ignore the occluded pixels or samples when performing subsequent shading operations. Although this approach avoids performing shading operations related to occluded geometry, the approach requires the entire 3D scene to be rendered twice, which results in additional processing overhead.
For example, operations such as vertex attribute fetch, vertex shading, and vertex tessellation must be performed twice in order to render the scene for the Z pre-pass and then again for the subsequent shading pass. These operations require additional processing cycles and consume additional power. In particular, vertex attribute fetch operations generally require access to off-chip dynamic random access memory (DRAM), which can be quite costly from a power perspective. Graphics primitives also must be obtained from memory for each rendering. Performing such operations consumes memory bandwidth and also increases load on the central processing unit (CPU), which likewise increases power consumption.
Power considerations are becoming ever more important across all types of computer system implementations, but have already become especially important in mobile implementations, given that mobile devices have limited power resources. Therefore, to the extent possible, unnecessary operations that lead to additional processing cycles and power consumption, like those described above with respect to occluded geometry, should be avoided where possible.
As the foregoing illustrates, what is needed are more effective techniques for rendering graphics scenes that include occluded geometry.